package yt.demo.appcorequartz.impl;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yt.demo.appcommondb.base.BaseService;
import yt.demo.appcommondb.vo.ConditionVO;
import yt.demo.appcorequartz.entity.QuartzJob;
import yt.demo.appcorequartz.mapper.QuartzJobMapper;
import yt.demo.appcorequartz.service.IQuartzJobService;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class QuartzJobService extends BaseService<QuartzJob, QuartzJobMapper> implements IQuartzJobService {

    @Autowired
    public QuartzJobService(QuartzJobMapper mapper) {
        super(mapper, QuartzJob.class);
    }

    @Override
    protected List<ConditionVO<QuartzJob, ?>> whereConditions(QuartzJob params) {
        List<ConditionVO<QuartzJob, ?>> conditions = new ArrayList<>();
        if (params != null) {
            if (ObjectUtil.isNotEmpty(params.getJobName())) {
                conditions.add(ConditionVO.createCondition(QuartzJob::getJobName, "like", params.getJobName()));
            }
            if (ObjectUtil.isNotEmpty(params.getType())) {
                conditions.add(ConditionVO.createCondition(QuartzJob::getType, "eq", params.getType()));
            }
            if (ObjectUtil.isNotEmpty(params.getStatus())) {
                conditions.add(ConditionVO.createCondition(QuartzJob::getStatus, "eq", params.getStatus()));
            }
        }
        return conditions;
    }

}
